package emulator.unittest.hardware.memory;


import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import emulator.EmulatorException;
import emulator.hardware.debug.BusWatchException;
import emulator.hardware.memory.DebugMemoryBlock;

public class DebugMemoryWriteWatchTest {

	private DebugMemoryBlock memory;

	@Before
	public void setUp() throws Exception {
		memory = new DebugMemoryBlock(0x1000);
		memory.enableWriteWatch(0x200, 0x2ff, true);
	}

	@Test(expected= BusWatchException.class)
	public void testWriteWatchInside() throws EmulatorException
	{
		memory.write(0x200, 0xAA);
	}

	@Test
	public void testWriteWatchOutside() throws EmulatorException
	{
		memory.write(0x300, 0xAA);
		assertEquals(0xAA, memory.read(0x300));
	}

	@Test
	public void testWriteWatchIgnoresReads() throws EmulatorException
	{
		assertEquals(0, memory.read(0x200));
	}
}
